﻿using System;
using System.Windows;
using Csla.Xaml;
using Accounting.Library;

namespace csla4Skeleton.UI.SL.NghiepVu.Kho.K_PhieuXuatKho
{
    public partial class K_PhieuXuatKho_ListViewModel : ViewModel<K_PhieuXuatKhoList>
    {
        public K_PhieuXuatKho_ListViewModel(string mode)
        {
            BeginRefresh("GetK_PhieuXuatKhoList", mode);

        }

        public void GetK_PhieuXuatKho_ListViewModel(string mode)
        {
            BeginRefresh("GetK_PhieuXuatKhoList", mode);
        }

        public static readonly DependencyProperty SelectedItemProperty =
          DependencyProperty.Register("SelectedItem", typeof(K_PhieuXuatKhoInfo), typeof(K_PhieuXuatKho_ListViewModel), null);
        public K_PhieuXuatKhoInfo SelectedItem
        {
            get { return (K_PhieuXuatKhoInfo)GetValue(SelectedItemProperty); }
            set { SetValue(SelectedItemProperty, value); }
        }

        public void DeleteK_PhieuXuatKho(object sender, ExecuteEventArgs e)
        {
            if (e.MethodParameter != null)
            {
                //cast OrderID parameter
                int Khoa = Int16.Parse(e.MethodParameter.ToString());
                this.IsBusy = true;
                Accounting.Library.K_PhieuXuatKho.DeleteK_PhieuXuatKho(Khoa, (o, ex) =>
                {
                    BeginRefresh("GetK_PhieuXuatKhoList", BusinessConfiguration.Configuration.GridViewFetchMode);
                });
                this.IsBusy = false;
            }
        }

        public void DeleteK_PhieuXuatKho(int Khoa)
        {
            this.IsBusy = true;
            Accounting.Library.K_PhieuXuatKho.DeleteK_PhieuXuatKho(Khoa, (o, ex) =>
            {
                BeginRefresh("GetK_PhieuXuatKhoList", BusinessConfiguration.Configuration.GridViewFetchMode);
            });
            this.IsBusy = false;
        }
    }
}
